const db = uniCloud.database()
const dbCmd = db.command

module.exports = {
	_before: function () { // 通用预处理器
	},
	_timing: function() { // 定时器触发	
		db.collection('lesson').where({
			sTime: new RegExp(/^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])/)
		})
		.remove()
	},
	add: async (lesson) => {
		return await db.collection('lesson').add(lesson)
	},
	getByStatus: async (status) => {
		return await db.collection('lesson').where({
			status
		}).get()
	},
	deleteById: async (id) => {
		return await db.collection('lesson').where({
			_id: id
		}).remove()
	}
}
